function live(type){
	if(!scope.pagedata.item.video){
		return false;
	}
	require(["videojs"], function(video) {
		console.log('ready');
		/*var videoPlayer = $("#player").get(0);
		 if (typeof (videoPlayer) != "undefined") {
				var myPlayer = video('player');
				myPlayer.dispose();
		}
		var id='player'
		$("#my-videoblock").html("<video id='" + id + "' class='video-js vjs-default-skin vjs-big-play-centered video' poster='' loop preload='auto' x-webkit-airplay='allow' x5-video-player-type='h5' x5-video-player-fullscreen='true' playsinline webkit-playsinline='true'><source id='source' src='' type='application/x-mpegURL'></video>");
         //设置资源路径
		$("#player").attr("poster", scope.tomedia(scope.pagedata.item.image));
        $("#player").attr("src", scope.tomedia(scope.pagedata.item.video));
		$("#source").attr("src", scope.tomedia(scope.pagedata.item.video));*/
		//$('.btn-play').show();
		window['videojs'] = video;
		var modal = {
			wsClient: false,
			wsConfig: scope.pagedata.wsConfig,
			wsConnected: false,
			wsBanned: {all: false, self: false},
			status: 0,
			realOnline: 0,
			showOnline: 0,
			wsCanAt: false,
			wsCanRepeal: false,
			msgAt: {},
			lastliketime: 0,
			inputTip: ['跟大家说点什么吧...', '点击键盘回车也可发送信息哦~']
		};
		console.log('modal');
		require(['/core/resource/components/videojs/video-contrib-hls.min.js'], function (videojs) {
				console.log('videojs'+scope.pagedata.item.id);			
				modal.initInternal();
		});
		modal.initInternal = function (params) {
			modal.wsConfig = scope.pagedata.wsConfig;
			modal.roomid = modal.wsConfig.roomcount;
			modal.initWs();
			modal.initClick();
			modal.initPlayer();
			// 处理安卓播放中跳转后返回
			if(modal.wsConfig.isMobile ){
				console.log('安卓手机进入');
				modal.x5videoexitfullscreen();
			}

			setInterval(function () {
				var tipIndex = Math.floor(Math.random() * 3);
				if (tipIndex == 2 && !modal.wsCanAt) {
					tipIndex == 1
				}
				$('#input').attr('placeholder', modal.inputTip[tipIndex]);
				if (modal.wsConnected) {
					modal.wsSend('communication', {toUser: 'system'});
					modal.clickLike();
				}else{
					modal.initWs();
				}
			}, 8000);
			//隐藏对话
			$(".btn-hide").off("click").on("click",function () {
				$(".tab-content").hide();
				$(".btn-hide").hide();
				$(".btn-show").show();
			});
			$(".btn-show").off("click").on("click",function () {
				$(".tab-content").show();
				$(".btn-hide").show();
				$(".btn-show").hide();
			});
			//判断IOS版本兼容
			var ver = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
			if (ver){
				ver = parseInt(ver[1], 10);
				if(ver>=10){
					$(".block-video").css("z-index","10");
					return;
				}
			}
		};
		modal.initPlayer = function () {
			console.log('initPlayer');
			// 初始化播放器
			modal.initMyPlayer();
			// 处理播放器位置
			var playerHeight = $('body').width() * 0.56;
			if (!$('.fui-content').hasClass('fullscreen')) {
				setTimeout(function () {
				// $('.prompt').css('height', playerHeight + 'px');
				$('.prompt').css({height:'210px',position:'fixed',zIndex:'99',width:'100%'});
				}, 100);
			}
			var player = $('#player_html5_api')[0];
			if (!modal.wsConfig.isMobile || modal.wsConfig.isIos) {
				return
			}
			//进入全屏时触发
			player.addEventListener("x5videoenterfullscreen", function () {
				//alert('进入全屏时触发');
				$('.btn-play').hide();
				$('.block-title').show();
				scope.pagedata.tofullscreen=true
				scope.$evalAsync();
				//$('.fui-content').addClass('player-fullscreen');
				//var playerHeight = $('body').width() * 0.56;
			});
			//退出全屏时触发
			player.addEventListener("x5videoexitfullscreen", function () {
				modal.x5videoexitfullscreen();
			})
		};

		modal.initMyPlayer = function () {
			console.log('initMyPlayer');
			modal.myPlayer = window.videojs('player',{
				bigPlayButton : false,
				textTrackDisplay : false,
				posterImage: false,
				errorDisplay : false,
				controlBar : false,
				fluid:true,
				autoplay:true,
			},function(){
				this.on('loadedmetadata',function(){
					console.log('loadedmetadata');
					//加载到元数据后开始播放视频
					modal.startVideo();
				})
				this.on('ended',function(){
					console.log('ended')
				})
				this.on('firstplay',function(){
					console.log('firstplay');
					//alert('firstplay');
					var tryTimes = 0;
					clearInterval(modal.isFirstplay);
					if(!scope.pagedata.noupvideo){
						modal.isFirstplay = setInterval(function(){
							console.log('waiting'+tryTimes);
							var currentTime = modal.myPlayer.currentTime();
							if(currentTime == 0 && scope.pagedata.item.video && !scope.pagedata.noupvideo){
								//此时视频已卡主3s
								modal.myPlayer.play();
								//尝试6次播放后，如仍未播放成功提示
								if(++tryTimes >= 6){
									//scope.message('您的网速有点慢，请在自动刷新之后重新点击观看！','error');
									tryTimes = 0;
									var url = $('#player').attr('src');
									//console.log('url='+url);
									$.get(url, function(){});
									scope.pagedata.noupvideo=true;
									$('.btn-play').show();
									//window.location.reload();
								}
							}else{
								clearInterval(modal.isFirstplay);
								tryTimes = 0;
							}
						},1000);
					}
				})
				this.on('loadstart',function(){
					//开始加载
					console.log('loadstart')
				})
				this.on('loadeddata',function(){
					console.log('loadeddata');
					//微信端无法自动播放，先取消
					//$('.btn-play').hide();
				})
				this.on('seeking',function(){
					//正在去拿视频流的路上
					console.log('seeking')
				})
				this.on('seeked',function(){
					//已经拿到视频流,可以播放
					console.log('seeked')
				})
				this.on('waiting',function(){
					var tryTimes = 0;
					clearInterval(modal.isWaiting);
					if(!scope.pagedata.noupvideo){
						modal.isWaiting = setInterval(function(){
							console.log('2waiting'+tryTimes);
							var currentTime = modal.myPlayer.currentTime();
							if(currentTime == 0 && scope.pagedata.item.video && !scope.pagedata.noupvideo){
								//此时视频已卡主3s
								modal.myPlayer.play();
								//尝试6次播放后，如仍未播放成功提示
								if(++tryTimes >= 6){
									//scope.message('您的网速有点慢,请在自动刷新之后重新点击观看！');
									tryTimes = 0;
									var url = $('#player').attr('src');
									$.get(url, function(){});
									scope.pagedata.noupvideo=true;
									//window.location.reload();
								}
							}else{
								clearInterval(modal.isWaiting);
								tryTimes = 0;
							}
						},1000);
					}
					//modal.myPlayer.play();
				})
				this.on('pause',function(){
					console.log('pause')
				})
				this.on('play',function(){
					console.log('play');
				})
				this.on('error',function(){
					console.log('error');
				})
			});
		};

		modal.x5videoexitfullscreen = function () {
			var playerHeight = $('body').width() * 0.56;
			if($('.fui-content').hasClass('fullscreen')){
				
			}else {

			};
			$('.block-title').hide();
			$('.loading').hide();
			$('.btn-play').show();
			scope.pagedata.tofullscreen=false
			scope.$evalAsync();
		};
		modal.initWs = function () {
			return
		};
		modal.initClick = function () {
			console.log('initClick');
			$(document).on('click', '.btn-reconnect', function () {
				if (modal.wsConnected) {
					scope.message('当前已连接，如还提示请刷新');
					return
				}
			});
			$('.btn-play').click(function () {
				var url = $('#player').attr('src');
				if (url == '') {
					scope.message('视频获取失败或未设置');
					return
				};
				// $('#player').get(0).play();
				modal.myPlayer.play();
				$('.live-tips').hide();
				$('#goback').hide();
				// var url = $(this).data('url');
				// $.ajax({
				//     url: url,
				//     type: "GET",
				//     timeout: 1000,
				//     complete : function(XMLHttpRequest,status){ //请求完成后最终执行参数
				//         if(status=='timeout'){//超时,status还有success,error等值的情况
				//             modal.myPlayer.play();
				//         }
				//     }
				// });
			});
			$('#player')[0].addEventListener("ended", function () {
				$('.live-tips.play').show().siblings('.live-tips').hide()
			});
		};
		
		modal.clickLike = function () {
			var colors = ['#ffc510', '#ff4a4a', '#ff9141', '#fb7c63', '#05e0e8', '#24ec79', '#50b7ff', '#b9f110', '#59e4b5', '#fe76e9', '#b976fe', '#fea2d0', '#918eff'], cindex = Math.floor(Math.random() * 12);
			var icons = ['icon-aixin1', 'icon-gouwudai', 'icon-yifuicon122438', 'icon-juzi', 'icon-liwu', 'icon-aixin', 'icon-flower1', 'icon-shuiguo', 'icon-kafei'], iindex = Math.floor(Math.random() * 8);
			var x = 200, y = 400;
			var rand = parseInt(Math.random() * (x - y + 1) + y);
			$('.fui-content').append('<div class="ico-like" style="color: ' + colors[cindex] + ';"><i class="icon ' + icons[iindex] + '"></i></div>');
			$(".ico-like").animate({bottom: "800px", opacity: "0", right: rand,}, 3000, null, function () {
				$(this).remove()
			})
		};
		modal.startVideo= function() {
			modal.myPlayer.play();
			//微信内全屏支持
		  /*  document.getElementById('player').style.width = window.screen.width + "px";
			document.getElementById('player').style.height = window.screen.height + "px";*/

			//判断开始播放视频，移除高斯模糊等待层
			var isVideoPlaying = setInterval(function(){
				var currentTime = modal.myPlayer.currentTime();
				if(currentTime > 0 || !scope.pagedata.item.video){
					$('.vjs-poster').remove();
					clearInterval(isVideoPlaying);
				}
			},200);
			//判断视频是否卡住，卡主3s重新load视频
			var lastTime = -1,
				tryTimes = 0;
			clearInterval(modal.isVideoBreak);
			modal.isVideoBreak = setInterval(function(){
				var currentTime = modal.myPlayer.currentTime();
				console.log('currentTime'+currentTime+'lastTime'+lastTime);

				if(currentTime == lastTime && scope.pagedata.item.video){
					//此时视频已卡主3s
					//设置当前播放时间为超时时间，此时videojs会在play()后把currentTime设置为0
					modal.myPlayer.currentTime(currentTime+10000);
					modal.myPlayer.play();

					//尝试6次播放后，如仍未播放成功提示刷新
					if(++tryTimes > 6){
						scope.message('您的网速有点慢，请在自动刷新之后重新点击观看！');
						tryTimes = 0;
					}
				}else{
					lastTime = currentTime;
					tryTimes = 0;
				}
			},3000)

		}
		return modal
});
}